<?php
using("Utils_HashMap");

class Tests_Utils_HashMap extends UnitTestCase {
	/**
	 * Hashmap
	 *
	 * @var Utils_HashMap
	 */
	private $_map;
	
	public function testConstruct() {
		$this->_map = new Utils_HashMap();
		$this->assertTrue(is_a($this->_map, "Utils_HashMap"));
	}
	
	public function testPut() {
		$this->assertFalse($this->_map->put(123, 123));
		$this->assertTrue($this->_map->put("123", 123));
	}
	
	public function testRemove() {
		$this->_map->put("123", 123);
		$this->assertFalse($this->_map->remove(123));
		$this->assertFalse($this->_map->remove("456"));
		$this->assertTrue($this->_map->remove("123") == 123);
	}
	
	public function testGet() {
		$this->_map->put("123", 123);
		$this->assertFalse($this->_map->get(123) == 123);
		$this->assertTrue($this->_map->get("123") == 123);
	}
	
	public function testIterate() {
		try {
			$this->_map->put("one", 123);
			$this->_map->put("two", 456);
			$this->_map->put("three", 789);
			foreach ($this->_map as $key) {
				$test .= $this->_map->get($key);
			}
			$this->assertTrue($test == "123456789");
		} catch (Exception $e) {
			$this->assertTrue(false);
		}
	}
}
?>